<?php
	$this->load->view('logged_in/components/header', array('current_page' => 2));
	$CI = & get_instance();
	$CI->load->model(array('user_model'));
	$CI->load->library('session');
	$user = $CI->user_model->getInfo($CI->session->userdata('userid'));
?>

	<div id="main-wrapper" style="width: 60%; margin: 0 auto; border-radius: 15px;">
		<div class="10u" style="margin: 0 auto">

			<h2 class="profile_h2">Avatar</h2>
			<?php
				if(isset($update_avatar))
					echo '<h4 class="profile_h4" style="color: #ffa03a">'.$update_avatar.'</h4>';
			?>
			<div class="5u" style="margin: 0 auto">
				<img style="width: 100%; border-radius: 15px" src="<?php echo base_url().'images/avatar/'.$user['image']?>">
			</div>
			<form style="margin: 0 auto; width: 80%" name="frmEdit"
			      action="<?php echo base_url().'profile/update_avatar'?>"
			      id="frmEdit" method="post"  enctype="multipart/form-data">
				<div class="input-group input-group-lg">
					<input id="uploadFile" class="form-control" placeholder="Upload Avatar" disabled="disabled"/>

					<div class="input-group-addon btn-lg fileUpload btn btn-primary"
					     style=" position: relative; overflow: hidden; background-color: #5cb85c; border-color: #4cae4c; color: #ffffff">
						<span>Upload</span>
						<input id="uploadBtn" name="image" type="file" class="upload"
						       style="position: absolute; top: 0; right: 0; margin: 0; padding: 0; font-size: 20px; cursor: pointer; opacity: 0; filter: alpha(opacity=0);"
						       onchange='document.getElementById("uploadFile").value = this.value;'/>
					</div>
				</div>
				<br/>
				<input type="submit" name="ok" class="btn-lg btn-success" value="Change Avatar"/><br/>
				<br/>
			</form>


<!--    information  -->
			<h2  class="profile_h2">Info</h2>
			<?php
			if(isset($update_info))
				echo '<h4 class="profile_h4" style="color: #ffa03a">'.$update_info.'</h4>';
			?>
			<form style="margin: 0 auto; width: 80%" name="frmEdit" id="frmEdit"
			      action="<?php echo base_url().'profile/update_info'?>" method="post"  enctype="multipart/form-data">

				<div class="input-group input-group-lg">
					<span class="input-group-addon">Username</span>
					<input type="text" name="" value="<?php echo $user['username']?>" readonly id="" class="form-control">
				</div>
				<br/>

				<div class="input-group input-group-lg">
					<span class="input-group-addon">Full name</span>
					<input type="text" name="name" value="<?php echo $user['name']?>" id="name" class="form-control">
				</div>
				<br/>

				<div class="input-group input-group-lg">
					<span class="input-group-addon">Address</span>
					<input type="text" name="address" value="<?php echo $user['address']?>"  id="address" class="form-control">
				</div>
				<br/>

				<div class="btn-group">
								<span class="btn btn-default btn-lg">
									<input name="gender" id="male" value="1" type="radio" class="radio-inline" <?php echo $user['gender'] == 1 ? 'checked="checked' : ''?>
									       style="margin: auto 0"/>
									<label for="male">Male</label>
								</span>
								<span class="btn btn-default btn-lg">
									<input name="gender" id="female" value="2" type="radio" class="radio-inline" <?php echo $user['gender'] == 0 ? 'checked="checked' : ''?>
									       style="margin: auto 0"/>
									<label for="female">Female</label>
								</span>
				</div>
				<br/>
				<br/>
				<input type="submit" name="ok" class="btn-lg btn-success" value="Update Info"/><br/>
				<br/>
			</form>

<!--        Email       -->
			<h2 class="profile_h2">Email</h2>
			<form style="margin: 0 auto; width: 80%" name="frmEdit" id="frmEdit"
			      action="<?php echo base_url().'profile/update_email'?>" method="post"  enctype="multipart/form-data">

				<div class="input-group input-group-lg">
					<span class="input-group-addon">Email</span>
					<input type="text" name="email"  value="<?php echo $user['email']?>" id="email" class="form-control">
				</div>
				<br/>

				<input type="submit" name="ok" class="btn-lg btn-success" value="Change Email"/>
				<br/>
				<br/>
			</form>

<!--	    password        -->
			<h2 class="profile_h2">Password</h2>
			<?php
			if(isset($change_pass))
				echo '<h4 class="profile_h4" style="color: #ffa03a">'.$change_pass.'</h4>';
			?>
			<form style="margin: 0 auto; width: 80%" name="frmEdit" id="frmEdit"
			      action="<?php echo base_url().'profile/change_pass'?>" method="post"  enctype="multipart/form-data">
				<div class="input-group input-group-lg">
					<span class="input-group-addon">Old Password</span>
					<input type="password" name="oldpass" value="" id="lname" class="form-control">
				</div>
				<br/>

				<div class="input-group input-group-lg">
					<span class="input-group-addon">New Password</span>
					<input type="password" name="password" value="" id="lname" class="form-control">
				</div>
				<br/>

				<div class="input-group input-group-lg">
					<span class="input-group-addon">Re-Password</span>
					<input type="password" name="repassword" value="" id="lname"  class="form-control">
				</div>
				<br/>
				<input type="submit" name="ok" class="btn-lg btn-success" value="Change Password"/><br/>
			</form>
		</div>
	</div>
<?php
$this->load->view('logged_in/components/footer');
?>